package com.javafactroy.kunlong.framework.batch;

import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
@ConditionalOnProperty(prefix = "spring.datasource.oracle", name = "enabled", havingValue = "true")
public class JobRunner {
    @Autowired
    private JobLauncher jobLauncher;
    @Autowired
    private Job simpleJob;
    //@Autowired
    //private Job importPersonJob;

    public void run( ) throws Exception {
        JobParameters jobParameters = new JobParametersBuilder()
                .addLong("date", System.currentTimeMillis())
                .toJobParameters();
        jobLauncher.run(simpleJob, jobParameters);
        //jobLauncher.run(importPersonJob, jobParameters);

  }
}
